package com.dragon.codefx.constant;

import lombok.Getter;

/**
 * 查询方式
 *
 * @author lsc
 * @date 2024/3/11 11:59
 **/
@Getter
public enum QueryType {
    //多字段模糊
    MORE("MORE", "多字段模糊")
    //相等
    , EQUAL("EQUAL", "相等")
    //不等于
    , NOT_EQUAL("NOT_EQUAL", "不等于")
    //模糊查询
    , LIKE("LIKE", "模糊查询")
    //大于等于
    , GREATER_THAN("GREATER_THAN", "大于等于")
    // 大于
    , GREATER_THAN_NQ("GREATER_THAN_NQ", "大于")
    //小于等于
    , LESS_THAN("LESS_THAN", "小于等于")
    //小于
    , LESS_THAN_NQ("LESS_THAN_NQ", "小于")
    //左模糊查询
    , LEFT_LIKE("LEFT_LIKE", "左模糊查询")
    //右模糊查询
    , RIGHT_LIKE("RIGHT_LIKE", "右模糊查询")
    //包含
    , IN("IN", "包含")
    //不包含
    , NOT_IN("NOT_IN", "不包含")
    //between
//    , BETWEEN
    //不为空
    , NOT_NULL("NOT_NULL", "不为空")
    //为空
    , IS_NULL("IS_NULL", "为空");

    private final String value;
    private final String label;


    QueryType(String value, String label) {
        this.label = label;
        this.value = value;
    }

    public static QueryType getByValue(String value) {
        for (QueryType queryType : values()) {
            if (queryType.value.equals(value)) {
                return queryType;
            }
        }
        return null;
    }
}
